package com.fare.fdc.action;

import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.stereotype.Controller;

import com.fare.taluo.BaseFdcAction;
import com.fare.taluo.application.freight.FreightMonitorLowPriceForFlightApplication;
import com.fare.taluo.application.freight.FreightMonitorSettingsApplication;
import com.fare.taluo.vo.fetl.FreightMonitorVO;
import com.fare.taluo.vo.freight.FreightMonitorSettingsVO;

@Controller("freightMonitorLowPriceForFlightInfoAction")
@Namespace("/")
public class FreightMonitorLowPriceForFlightInfoAction extends BaseFdcAction {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 4906498523852523359L;

	@Resource(name = "freightMonitorSettingsApplication")
	private FreightMonitorSettingsApplication freightMonitorSettingsApplication;
	
	@Resource(name="freightMonitorLowPriceForFlightApplication")
	private FreightMonitorLowPriceForFlightApplication freightMonitorLowPriceForFlightApplication;
	
	
	private Long id;
	
	private String flightNuber;
	
	private String xmlForCabinType;
	
	private String xmlForCabinName;
	
	public void findLowPriceForFlightInfoXML(){
		try {
			FreightMonitorSettingsVO freightVO =freightMonitorSettingsApplication.getMonitorById(id);
			 if(freightVO!=null){
				List<FreightMonitorVO>	 list = freightMonitorLowPriceForFlightApplication.findFreightMonitorVOByTimeAndNO(freightVO.getOpDateString(),freightVO.getDepartDateString(), flightNuber,30);
				//if(list!=null && list.size()>0){
				xmlForCabinType =freightMonitorLowPriceForFlightApplication.findXMLforFreightMonitor(list, 1);
				super.toJSONOut(xmlForCabinType);
				//}
				//xmlForCabinName =freightMonitorLowPriceForFlightApplication.findXMLforFreightMonitor(list, 2);
			 }
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public void findPriceForFlightInfoByCabinNameXML(){
		try {
			FreightMonitorSettingsVO freightVO =freightMonitorSettingsApplication.getMonitorById(id);
			 if(freightVO!=null){
				List<FreightMonitorVO>	 list = freightMonitorLowPriceForFlightApplication.findFreightMonitorVOByTimeAndNO(freightVO.getOpDateString(),freightVO.getDepartDateString(), flightNuber,30);
			//	if(list!=null && list.size()>0){
				xmlForCabinName =freightMonitorLowPriceForFlightApplication.findXMLforFreightMonitor(list, 2);
				super.toJSONOut(xmlForCabinName);
			//	}
			 }
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public FreightMonitorSettingsApplication getFreightMonitorSettingsApplication() {
		return freightMonitorSettingsApplication;
	}

	public void setFreightMonitorSettingsApplication(
			FreightMonitorSettingsApplication freightMonitorSettingsApplication) {
		this.freightMonitorSettingsApplication = freightMonitorSettingsApplication;
	}
	
	

	public FreightMonitorLowPriceForFlightApplication getFreightMonitorLowPriceForFlightApplication() {
		return freightMonitorLowPriceForFlightApplication;
	}


	public void setFreightMonitorLowPriceForFlightApplication(
			FreightMonitorLowPriceForFlightApplication freightMonitorLowPriceForFlightApplication) {
		this.freightMonitorLowPriceForFlightApplication = freightMonitorLowPriceForFlightApplication;
	}


	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getFlightNuber() {
		return flightNuber;
	}

	public void setFlightNuber(String flightNuber) {
		this.flightNuber = flightNuber;
	}


	public String getXmlForCabinType() {
		return xmlForCabinType;
	}


	public void setXmlForCabinType(String xmlForCabinType) {
		this.xmlForCabinType = xmlForCabinType;
	}


	public String getXmlForCabinName() {
		return xmlForCabinName;
	}


	public void setXmlForCabinName(String xmlForCabinName) {
		this.xmlForCabinName = xmlForCabinName;
	}
	
	
}
